home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
8bit
/
language
/
albug.m65
< prev
next >
Wrap
Text File
|
1995-04-22
|
40KB
|
1,761 lines
;<HESS.ATARI>ALBUG.M65.71 12-Mar-82 15:25:26, Edit by HESS
.TITLE LBUG - 6502 DEBUGGER (ATARI VERSION)
; (C) Ted Hess, Hudson, Ma. 1977,1978,1979,1980,1981,1982
.LIST MB ;LIST BINARY IN MACROS
.NLIST TOC ;NO TABLE OF CONTENTS
.ENABL LC ;ALLOW LOWER CASE TEXT
; INVOKE SYSTEM MACROS FOR PARAMETER DEFINITIONS
.MCALL ATARI
.MCALL M6502
ATARI
M6502
;***** THINGS TO DO ******
;
; 1) Re-write parser for DDT syntax and better defaults
; Make better use of ATARI keyboard!
;
;*************************
;LBUG STORAGE ASSIGNMENTS (PAGE 0)
INBUF =$E0 ;INPUT BUFFER (2 BYTES)
POINT =$E2 ;OPEN CELL ADDRS (2 BYTES)
AC =$E4 ;ACCUMULATOR
XREG =$E5 ;X INDEX
YREG =$E6 ;Y INDEX
PS =$E7 ;PROCESSOR STATUS REG
SP =$E8 ;STACK POINTER
;RANDOM CONSTANTS AND PARAMETERS
DSKCOD =$31 ;DISK DEVICE CODE
DSKR ='R ;DISK READ COMMAND
DSKW ='W ;DISK WRITE COMMAND
MAXBP =8 ;EIGHT IS TRADITIONAL (BREAK POINTS)
LNSCR =24 ;# OF LINES ON SCREEN
LPP =55 ;LINES/PAGE ON PRINTER
.IIF NDF,LORG, LORG= $8000 ;DEFAULT PROG ORIGIN
;MAIN ENTRY POINT - NORMAL START (LORG)
;RESET ENTRY - REMOVE BREAKPOINTS (LORG+3)
SETPC PPC,LORG
;NORMAL START ENTRY
START: JMP STRT1
JMP RST
VERS: .ASCII <.ATCLR>"Lady Bug - V4.0, (C) Ted Hess 1981"<.ATEOL>
ROF: .BLKB 1 ; REGISTER OPENED FLAG
; 0 = CLOSED
; $1 = HEX/OCTAL
; $FF = SYMBOLIC
CF: .BLKB 1 ;ADDRESS FLAG
; $FF = NO ADDRESSES TYPED
; $00 = ONE ADDRESS TYPED
; $01 = COMMA TYPED
PRPC: .BLKB 2 ;PROGRAM COUNTER (AT BREAK)
LENGTH: .BLKB 1 ; LENGTH OF INSTR (0 := 1-BYTE)
PFRMT: .BLKB 1 ; PRINT FORMAT INDEX
VEB: .BLKB 2 ;4 BYTE PROGRAM BLOCK
LMNEM: .BLKB 1 ;(VEB+2) TEMP FOR MNEMONIC PRINT
RMNEM: .BLKB 1 ;(VEB+3) ...
STARTA: .BLKB 2 ;STARTING ADDRESS
ENDAD: .BLKB 2 ;ENDING ADDRESS
TEMPX: .BLKB 1 ;NEED TO SAVE X AROUND OS
TEMPY: .BLKB 1 ;TEMP SAVE Y
SNGLF: .BLKB 1 ;SINGLE STEP FLAG
BPN: .BLKB 1 ;BREAKPOINT NUMBER OR 0
DRVNO: .BLKB 1 ;DISK UNIT #
PIOCB: .BLKB 1 ;IOCB INDEX FOR PRINTER/EDITOR
PNTF: .BLKB 1 ; PRINTER FLAG
TABPT: .BLKB 1 ;INDEX INTO TAB RING
TABRNG: .BLKW 8 ;RING BUFFER FOR TAB/UNTAB
;BREAKPOINT TABLES
BPINS: .BLKB MAXBP ;SAVE INSTR
BPCNT: .BLKB MAXBP ;PROCEED COUNT
BPLOCL: .BLKB MAXBP ;LOCATION LOW
BPLOCH: .BLKB MAXBP ;LOCATION HIGH
;RESET ENTRY
RST: CALL REMB ;REMOVE BREAK POINTS
; NORMAL STARTUP JOINS HERE
STRT1: CALL INITS ;INITIALIZE THINGS
TYPE VERS ;OUTPUT HERALD
CLR <SNGLF,BPN,DRVNO,PS> ;CLEAR SS FLAG, ETC.
SET2 BREAK,VBREAK ;BREAK POINT ENTRY
TSX ;SAVE CURRENT STACK POINTER
STX SP
JMP RALL ;CLEAR ALL BREAK POINTS
;MAIN DECODER
ERR: CALL ERRFST ;PRINT <BELL>?
DCD: CALL CLOSEP ;CLOSE PRINTER IF OPEN
CALL CRLFS ;PRINT CRLF
DCD4: CLR ROF ;CLOSE OPEN REG
LDX SP ;RESTORE STACK POINTER
TXS
SCAN: LDA #$FF ;SET UP ADDRESS FLAG
STA CF
CALL GETNUM ;INPUT SOMETHING
LDX CF ;GET QUANITY TYPED FLAG
BMI CLGL ;DO NOT DESTROY OLD VALUE FOR ' AND =
SCAN1: MOV2X INBUF,STARTA ;SET UP STARTING ADDRESS
;FALL INTO SPECAIL CHARACTER DECODER
;HERE TO CHECK LEGAL CHARACTER
CLGL: LDX #MAXL ;INIT INDEX
LGL1: CMP LGCH,X ;MATCH?
BEQ LGL2 ;YES - PROCEED
DEX ;NO - STEP TO NEXT
BPL LGL1 ;BRANCH IF MORE TO GO
BMI ERR ;ERROR IF NONE
;FOUND MATCH - DISPATCH
LGL2: TXA ;GET INDEX
LGL3: ASL A ; TIMES 2
TAX ; BACK TO X
LDA LDISP+1,X ;GET HIGH BYTE OF XFER
PHA ;PUT ON STACK
LDA LDISP,X ;GET XFER LOW
PHA ;STACK NOW HAS XFER ADDRS
LDA CF ;GET ARGUMENT FLAG IN AC
CMP #1 ;SET FLAGS BASED ON ONE
RET ;DISPATCH
ERRFST: LDA #.ATBEL ;RING BELL
CALL OUTSCH
LDA #'? ;THEN PRINT ?
JMP OUTSCH
;COMMA - SAVE INPUT AS STARTING ADDRESS
COMMA: LDA CF ;GET ARGUMENT FLAG IN AC
BNE ERR ;MUST BE ONE AND ONLY ONE ARGUMENT TYPED SO FAR
CALL GETNUM ;GET ANOTHER ARGUMENT
COMMA1: MOV2X INBUF,ENDAD ;SET UP ENDING ADDRESS
LDX CF ;GET ARGUMENT FLAG
CPX #2 ;CHECK TO SEE IF IT IS OPEN
BPL ERR ;NO THEN IT IS AN ERROR
BMI CLGL ;GO DISPATCH ON BREAK CHARACTER
;ESC SEEN (ECHO $)
ESC: LDA #'$
CALL OUTSCH
CALL GETSCH ;GET NEXT CHARACTER
SEC ;CLEAR BORROW
SBC #'1 ;CHECK FOR NUMBER
BMI ERR ;IF LESS THAN THEN IT IS AN ERROR
CMP #MAXBP ;IS IT LESS THAN MAXIMUM ALLOWABLE BREAKPOINT
BMI ESCB ;YES GO GET BREAKPOINT B
SBC #@20 ;CHECK FOR A
BMI ERR ;IF LESS THAN A IT IS AN ERROR
AND #@337 ;GET RID OF LOWERCASE BIT
CMP #'Z-@100 ;IS IT GREATER THAN Z
BPL ERR1 ;YES. REPORT ERROR
TAX ;PUT IT IN THE X REGISTER
LDA ARGNUM,X ;GET NUMBER OF ARGUMENTS
CMP CF ;IS IT CORRECT
BEQ 10$ ;YES. SKIP REST OF TEST
CMP #$80 ;IS IT ONE OR NONE FLAG
BNE ERR1 ;NO GIVE ERROR
LDA CF ;GET FLAG
CMP #1 ;LESS THAN ONE
BPL ERR1 ;NO. GO GIVE ERROR
10$: TXA ;GET INDEX BACK TO A
CLC
ADC #<DISP-LDISP>/2 ;CALC TABLE OFFSET
BNE LGL3 ;DISPATCH
ESCB: TAX ;SAVE BP NUMBER IN X
CALL GETSCH ;GET THE CHARACTER
AND #@337 ;GET RID OF CASE BIT
CMP #'B ;IS IT A B
BNE ERR1 ;NO. THEN IT IS AN ERROR
JMP BKPT1 ;YES. GO DO BREAKPOINT
;DOT (.) SEEN - SUBSTITUE CURRENT LOC
DOT: MOV2 POINT,INBUF ;PUT LOC INTO BUFFER
DOT1: CALL GETSCH ;GET ANOTHER CHARACTER
INC CF ;SAY QUANT TYPED
BNE COMMA1 ;GO SET UP ENDING ADDRESS
JMP SCAN1 ;BACK TO SCAN LOOP
;PERCENT SEEN - SPECIAL REGISTER
PERC: CALL GETSCH ;LOOK AT NEXT CHAR
AND #@337 ;GET RID OF CASE BIT
LDX #MAXS ; AND CHECK FOR SPECIAL
PERC1: CMP LGPC,X ;MATCH?
BEQ PERC2 ;???
DEX ;NO - STEP TO NEXT
BPL PERC1
ERR1: JMP ERR ;ERROR IF NO MORE
;SETUP DESIRED REGISTER ADDRS AS INPUT TYPED
PERC2: LDA PERAD,X ;GET ADDRS OF BYTE
STA INBUF ;STORE AS INPUT
CLR INBUF+1
BEQ DOT1 ;BACK TO INPUT LOOP
;CARRIAGE RETURN TYPED
CRET: CALL CLSE ;CLOSE OPEN REG IF ANY
JMP DCD ;RE-INIT THINGS
;SLASH TYPED - OPEN A REG IN SYMBOLIC
SLSH: BPL ERR1 ;IF MORE THAN ONE ARGUMENT IT IS AN ERROR
LDA #$FF ;SET ROF FLAG
BNE SLSH1 ;JOIN COMMON CODE
;SLASH TYPED - OPEN A REG (HEX)
BRAKET: BPL ERR1 ;IF MORE THAN ONE ARGUMENT IT IS AN ERROR
LDA #1 ;SET REG OPEN
SLSH1: STA ROF
CALL OUTSSP ;TYPE A SPACE
LDA CF ;ANYTHING TYPED
BNE 10$ ; ??
CALL INTPT ;YES - OPEN IT
10$: CALL PRTSCN ;GO DO OUTPUT
JMP SCAN
;LINE FEED - OPEN NEXT REG
LFD: BPL ERR1 ;IF MORE THAN ONE ARGUMENT IT IS AN ERROR
CALL CRLFS ;OUTPUT <EOL>
LFD0: LDA ROF ;CHECK TYPE
BMI LFDS ;DO SYMBOLIC NEXT INSTR
CALL CLSE ;CLOSE OPEN REG IF ANY
CALL INCPT ;STEP TO NEXT LOC
LFDC: INC ROF ;MARK OPEN HEX
LDX #'[ ;SLASH
CALL PRTSLC ;GO PRINT THE CONTENTS
JMP SCAN
LFDS: CALL PCADJ ;STEP OVER INSTR
STA POINT ;SAVE NEW PC
STY POINT+1
LFDS1: CALL PRTSLS ;GO PRINT LOCATION IN SYMBOLIC
JMP SCAN ;BACK TO MAIN COMMAND DECODER
;^ OR <BS> TYPED - OPEN PREVIOUS
BACK: BPL ERR1 ;IF MORE THAN ONE ARGUMENT IT IS AN ERROR
CALL CLSE ;CLOSE OPEN REG
CALL DECPT ;DECREMENT THE POINTER
CALL CRLFS ;PUT OUT A CARRIAGE RETURN LINE FEED
JMP LFDC ;COMMON CODE
;TAB GO TO ADDRESS IF IN SYMBOLIC MODE
TAB: BPL ERR1 ;ERROR IF MORE THAN 1 ARG
LDA ROF ;GET OUTPUT MODE FLAG
BPL ERR1 ;ONLY GET EFFECTIVE ADDRESS IF SYMBOLIC
LDX TABPT ;SAVE POINT
LDA POINT
STA TABRNG,X ;IN RING BUFFER
LDA POINT+1
STA TABRNG+8,X
INX ;STEP INDEX
TXA
AND #$07 ;MASK TO MOD 8 CNTR
STA TABPT ;STORE IT BACK
CALL CALCAD ;CALCULATE EFFECTIVE ADDRESS
MOV2 INBUF,POINT ;GET JMP ADDRESS
TAB1: CALL CRLFS ;PUT OUT CARRIAGE RETURN LINE FEED
JMP LFDS1 ;GO TYPE OUT NEW ADDRESS
; UNTABIFY - POP RING THEN TAB
UNTAB: BPL 5$ ;ERROR IF ANYTHING TYPED
LDA ROF ;REGISTER OPEN FLAG
5$: BPL ERR2 ;ERROR IF NOT SYMBOLIC MODE
LDA #$7 ;MASK FOR MOD 8 SUBTRACT
DEC TABPT ;DECREMENT INDEX
AND TABPT ;MASK IT
STA TABPT ;STORE RESULT
TAX ;XFER TO INDEX
LDA TABRNG,X ;FETCH SAVED VALUE
STA POINT ;RESTORE TO POINT
LDA TABRNG+8,X
STA POINT+1
JMP TAB1 ;FINISH THRU COMMON CODE
;EQUAL SIGN - TYPE IN OCTAL
TOC: BPL ERR2 ;IF MORE THAN ONE ARGUMENT IT IS AN ERROR
LDA STARTA ;GET CHARACTER IN A
STA PFRMT ;SAVE BYTE
LDX #3 ;TYPE 3 DIGITS
LDY #3 ; OF 3 BITS EACH
CLC ;INIT CARRY BIT
BCC 15$ ;SKIP FIRST SHIFT
10$: ASL PFRMT ;SHIFT LEFT
15$: ROL A ;GET BIT INTO AC
DEY ;COUNT BITS
BNE 10$ ;CONTINUE FOR 3 BITS
AND #@7 ;GRNTEE OIT
CALL HEXST1 ;TYPE OUT
LDY #3 ;RELOAD BIT COUNTER
DEX ;DECREMENT DIGIT COUNTER
BNE 10